package com.example.shiwu.view;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.example.shiwu.R;
import com.example.shiwu.model.MainInfo;
import com.example.shiwu.model.MainStatus;
import com.example.shiwu.util.BaseView;

public class MainStatusView extends BaseView<MainStatus> {

    public TextView temp,voltage,svoltage,gpsStatus,gpsPosition,inTemp;
    public Activity contexts;
    public View views;

    public MainStatusView(Activity context, int layoutResId, View view) {
        super(context, layoutResId);
        contexts = context;
        views = view;
    }

    @SuppressLint("InflateParams")
    @Override
    public View createView() {

        temp = views.findViewById(R.id.main_status_temp_val);
        voltage = views.findViewById(R.id.main_status_voltage_val);
        svoltage = views.findViewById(R.id.main_status_svoltage_val);
        gpsStatus = views.findViewById(R.id.main_status_gps_status_val);
        gpsPosition = views.findViewById(R.id.main_status_gps_position_val);
        inTemp = views.findViewById(R.id.main_status_in_temp_val);

        return super.createView();
    }

    @Override
    public void bindView(MainStatus data_) {
        super.bindView(data_ != null ? data_ : new MainStatus());

        temp.setText(data.getTemp());
        voltage.setText(data.getVoltage());
        svoltage.setText(data.getSvoltage());
        gpsStatus.setText(data.getGpsStatus());
        gpsPosition.setText(data.getGpsPosition());
        inTemp.setText(data.getInTemp());
    }
}
